const profileModel = require("../models/profileModel");

const ProfileService = {
  // 添加信息
  add: async (data) => {
    return profileModel.create({ ...data });
  },
  // 获取列表
  getList: async () => {
    return profileModel.find();
  },
  // 查询单个
  findId: async (_id) => {
    return profileModel.findOne({ _id });
  },
  // 更新单个
  upadte: async (_id, data) => {
    return profileModel.findOneAndUpdate(
      { _id },
      { $set: data },
      { new: true }
    );
  },
  // 删除
  delete: async (_id) => {
    return profileModel.deleteOne({ _id });
  },
};
module.exports = ProfileService;
